package com.jiuzhou.guanwang.jzcp.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jiuzhou.guanwang.jzcp.R;
import com.jiuzhou.guanwang.jzcp.base.BaseRecyclerAdapter;
import com.jiuzhou.guanwang.jzcp.base.BaseRecyclerHolder;
import com.jiuzhou.guanwang.jzcp.bean.NewsResult;

import java.util.List;

/**
 * @ explain:
 * @ author：xujun on 2016/10/18 16:42
 * @ email：gdutxiaoxu@163.com
 */
public class NewsAdapter extends BaseRecyclerAdapter<NewsResult> {
    private Context mContex;

    public NewsAdapter(Context context, List<NewsResult> datas) {
        super(context, R.layout.item_news, datas);
        mContex = context;
    }

    @Override
    public void convert(BaseRecyclerHolder holder, NewsResult item, int position) {
        holder.setText(R.id.tv_name, item.getTitle());
        holder.setText(R.id.tv_content, item.getContents());
        holder.setText(R.id.tv_date, item.getShorttitle());
//        TextView tagTv = holder.getView(R.id.tv_tag);
//        if( item.getAuthTag().contains("玩家")){
//            tagTv.setTextColor(mContex.getResources().getColor(R.color.red));
//            tagTv.setBackground(mContex.getResources().getDrawable(R.drawable.btn_with_border_red));
//        }else if(item.getAuthTag().contains("彩票")){
//            tagTv.setTextColor(mContex.getResources().getColor(R.color.blue1));
//            tagTv.setBackground(mContex.getResources().getDrawable(R.drawable.btn_with_border_blue));
//        }else if(item.getAuthTag().contains("TV")){
//            tagTv.setTextColor(mContex.getResources().getColor(R.color.orange));
//            tagTv.setBackground(mContex.getResources().getDrawable(R.drawable.btn_with_border_orange));
//        }else{
//            tagTv.setTextColor(mContex.getResources().getColor(R.color.purple));
//            tagTv.setBackground(mContex.getResources().getDrawable(R.drawable.btn_with_border_purple));
//        }
//        holder.setText(R.id.tv_tag, item.getAuthTag());
        ImageView headView = holder.getView(R.id.icon);
        if(!TextUtils.isEmpty(item.getImage())){
            Glide.with(this.mContext).load(item.getImage()).into(headView);
        }else{
            Glide.with(this.mContext).load(R.drawable.no_picture).into(headView);
        }
    }

}
